<template>
  <div class="wepay-dialog">
    <el-dialog title="微信转账" :visible.sync="dialogShow" center>
      <div style="text-align: center">
        <img style="height: 300px" :src="wepayQRCodeImgSrc" />
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleCancel">取 消</el-button>
        <el-button type="primary" @click="handleConfirm">已确认转账</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "WePayDialog",
  props: {
    wepayQRCodeImgSrc: {
      type: String,
      default: null,
    },
    confirmAutoClose: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {
      dialogShow: false,
    };
  },
  methods: {
    // 外部调用
    open() {
      this.dialogShow = true;
    },
    // 外部调用
    close() {
      this.dialogShow = false;
    },
    handleCancel() {
      this.$emit("cancel");
      this.dialogShow = false;
    },
    handleConfirm() {
      this.$emit("confirm");
      if (this.confirmAutoClose) this.dialogShow = false;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
